Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 2 - Shape Objects / About Shape Objects


Shape Properties

The properties of a shape object for the most part define the basic geometric characteristics of the shape. Shape objects have nine accessible properties, as shown in Figure 2-2. Note that, because a shape is an object and not a data structure, the order of the properties as shown in Figure 2-2 is completely arbitrary. Properties in italics are references to other objects.

Figure 2-2 The shape object and its properties

The first six properties are specific to shape objects alone. They determine a shape's geometric type, geometric structure, fill, and references to other objects:

The remaining three shape properties are common to many QuickDraw GX objects (including styles, inks, and others):

Shape Type

A shape object's type property specifies what sort of geometry the shape has. Table 2-1 lists the defined constants for each shape type and describes what each one means. (Note that the empty and full shape types are unusual, in that they have no specific geometry; they are used for specialized operations other than drawing.) The constants are defined in the gxShapeTypes enumeration.
Shape types (Continued)
ConstantValueExplanation
gxEmptyType1An empty shape. It has no geometry, no contents,
and no bounds. The intersection of two shapes that do not touch is the empty shape. You can use empty shapes as a starting point for collecting graphic elements. This shape type is described in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxPointType2A point shape. Its geometry contains two fixed-point coordinate values representing the location of the point. This shape type is described in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxLineType3A line shape. Its geometry contains two point geometries--the starting point and the ending point. This shape type is described in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxCurveType4A curve shape. Its geometry contains three point geometries--a starting point, an ending point, and
a control point--which together describe a quadratic Bézier curve. This shape type is described in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
 
gxRectangleType5A rectangle shape. Its geometry contains four fixed-point values--representing the coordinates
of the left, top, right, and bottom corners of the rectangle. This shape type is described in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxPolygonType6A polygon shape. Its geometry includes any number of separate multiple-point polygon contours, each contour consisting of straight line segments connecting its points. This shape type is described
in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxPathType7A path shape. Its geometry includes any number of separate multiple-point path contours, each contour consisting of straight or curved line segments connecting its points. This shape type is described
in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxBitmapType8A bitmap shape. Its geometry contains information about the bitmap's size, shape, and color, as well as the pixel image itself. This shape type is described in the bitmap shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxTextType9A text shape. Its geometry contains a string of characters to be drawn with uniform stylistic properties such as font family, font size, and style. This shape type is described in the text shapes
chapter of Inside Macintosh: QuickDraw GX
Typography.
gxGlyphType10A glyph shape. Its geometry contains a string of glyphs, each of which may have its own typestyle when drawn. This shape type is described in the glyph shapes chapter of Inside Macintosh: QuickDraw GX Typography.
gxLayoutType11A layout shape. Its geometry contains a string of characters plus sophisticated formatting information that affects how the text is displayed. This shape
type is described in the layout shapes chapter of
Inside Macintosh: QuickDraw GX Typography.
gxFullType12A full shape. It encompasses all of the
QuickDraw GX coordinate space. Inverting an
empty shape produces a full shape. The full shape contains every other shape and no other shape contains the full shape. You can use full shapes to specify the largest possible clip area for maximum visibility when drawing. This shape type is described in the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxPictureType13A picture shape. It is a collection of other shapes, including possibly other picture shapes. This shape type is described in the picture shapes chapter of Inside Macintosh: QuickDraw GX Graphics.

Shape Geometry

Most shape geometries are defined in terms of points in a coordinate space. QuickDraw GX coordinates are pairs of fixed-point numbers (of type Fixed), as defined in the mathematics chapter of Inside Macintosh: QuickDraw GX Environment and Utilities. QuickDraw GX coordinate spaces are described in the chapter "View-Related Objects" in this book.

Figure 2-3 summarizes the contents of the geometry property for each type of QuickDraw GX shape (except empty and full types, which have no geometry). In the figure, elements of the geometry that are references (or arrays of references) to other objects are shown in italics. For a diagram showing all the properties of the basic QuickDraw GX objects, see the chapter "Introduction to Objects" in this book. For a diagram showing all the properties of the printing objects, see the introductory chapter of Inside Macintosh: QuickDraw GX Printing.

Figure 2-3 Shape geometry for each type of QuickDraw GX shape

The structures of individual shape geometries are specific to each shape type and thus are not described here. See the chapters of Inside Macintosh: QuickDraw GX Graphics and Inside Macintosh: QuickDraw GX Typography specified in Table 2-1 of the previous section for more information.

Nevertheless, some of the functions that affect shape geometry are common to all types of shapes, and are therefore described in this chapter. The section "Copying the Geometry From One Shape to Another" beginning on page 2-29 discusses how to copy the geometry between shapes. The section "Directly Manipulating a Shape's Geometry" beginning on page 2-34 discusses how to get direct access to a shape's geometry--as a data structure rather than as an object property--in order to modify it. Also, Figure 2-3 on page 2-12 of this chapter summarizes the contents of the geometry of each type of QuickDraw GX shape.

Shape Fill

Each shape object has a fill property. The shape fill specifies how QuickDraw GX interprets the geometry of the shape: how the shape is drawn, how the shape is hit-tested, and how certain geometric operations, like intersection or union, interpret the shape. Table 2-2 lists the defined constants for shape fill and describes what each one means. (Note that some shape fills have two or more equivalent names.) The constants are defined in the gxShapeFills enumeration.
Table 2-2 Shape fills (Continued)
ConstantValueExplanation
gxNoFill0No fill--the shape is not filled at all. QuickDraw GX does not draw a shape with this shape fill and you may not perform geometric operations on it. You can use this shape fill to temporarily hide shapes or to prevent parts of a picture from drawing.
gxOpenFrameFill1Open-frame fill--the shape is outlined instead of filled. With this shape fill, QuickDraw GX interprets the shape as a connected series of straight or curved lines from the starting point of the shape geometry to the ending point
(but not back to the starting point again).
gxFrameFill1Framed fill (same as gxOpenFrameFill).
gxClosedFrameFill2Closed-frame fill--the shape is outlined instead of filled. As with the open-frame fill, QuickDraw GX interprets the shape as a series of lines (or curves) from the starting point of the shape geometry to the ending point. However, in this case, QuickDraw GX also includes a line (or curve) from the ending point to the starting point, thus closing the contour.
 
gxHollowFill2Hollow fill (same as gxClosedFrameFill).
gxEvenOddFill3Even-odd fill--the shape is filled using
the even-odd rule. See Figure 2-4 for an
illustration of this rule; see Inside Macintosh: QuickDraw GX Graphics for further explanation.
gxSolidFill3Solid fill (same as gxEvenOddFill).
gxWindingFill4Winding fill--the shape is filled using
the winding-number rule. See Figure 2-4 on page 2-14 for an illustration of this rule; see Inside Macintosh: QuickDraw GX Graphics for further explanation.
gxInverseEvenOddFill5Inverse even-odd fill--the shape is filled in
an opposite manner from the even-odd rule; everything not filled using the even-odd rule is filled using this rule. See Inside Macintosh: QuickDraw GX Graphics for further explanation.
gxInverseSolidFill5Inverse solid fill
(same as gxInverseEvenOddFill).
gxInverseFill5Inverse fill
(same as gxInverseEvenOddFill).
gxInverseWindingFill6Inverse winding fill--the shape is filled using the winding-number rule and then inverted. See Inside Macintosh: QuickDraw GX Graphics for further explanation.

Figure 2-4 Even-odd and winding fills

Note that framed fill, hollow fill, and solid fill are alternative names for open-frame fill, closed-frame fill, and even-odd fill, respectively, and that both inverse solid fill and inverse fill are alternate names for inverse even-odd fill.

Not all shape fills make sense for all shape types. Table 2-3 shows the acceptable shape fills for each shape type (the alternative names are not listed). Note that empty and full shapes are permitted to have certain fill types even though they have no geometry.
Table 2-3 Valid shape fills for each shape type
Shape typesValid shape fills
EmptygxNoFill
gxInverseEvenOddFill
gxInverseWindingFill
FullgxNoFill
gxEvenOddFill
gxWindingFill
gxInverseEvenOddFill
gxInverseWindingFill
Point, line, curvegxNoFill
gxOpenFrameFill
RectanglegxNoFill
gxClosedFrameFill
gxEvenOddFill
gxWindingFill
gxInverseEvenOddFill
gxInverseWindingFill
Polygon, pathany shape fill
Text, glyph, layoutgxNoFill
gxEvenOddFill
gxWindingFill
Bitmap, picturegxNoFill
gxEvenOddFill

For additional examples of how different shape fills can affect the appearance of different types and geometries of shapes, see the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics.

Shape Attributes

Each shape object includes a property that is a set of attributes, a group of flags that specify certain aspects of the shape's behavior. Table 2-4 lists the defined shape attribute constants and describes what each one means. The constants are defined in the gxShapeAttributes enumeration.
Shape attributes (Continued)
ConstantValueExplanation
gxNoAttributes0x0000No shape attributes are set. You can use
this attribute to clear or test against the current value of a shape's attributes.
gxDirectShape0x0001QuickDraw GX is to load the shape into directly accessible memory. Set this flag
for shape objects that you don't want
stored in accelerator card memory, or
whose geometric structures you want
to manipulate directly (see "Directly Manipulating a Shape's Geometry" beginning on page 2-34). The attributes gxDirectShape and gxRemoteShape
are exclusive; do not set them both.
gxRemoteShape0x0002QuickDraw GX is to load the shape into remote memory (memory used by an accelerator card), if possible. When this
flag is set, the shape might draw faster but you might not be able to edit the shape's geometry directly (see "Directly Manipulating a Shape's Geometry" beginning on page 2-34). The attributes gxRemoteShape and gxDirectShape
are exclusive; do not set them both.
gxCachedShape0x0004QuickDraw GX is to prepare the shape for the fastest possible drawing by caching it compressed in an offscreen bitmap. (See "Caching Shape Objects" beginning on page 2-27; also, compare this with using
the GXCacheShape function, described on page 2-62.)
gxLockedShape0x0008QuickDraw GX is to prohibit changes to
the shape's geometry or the shape's disposal. You can use this flag in the debugging version of QuickDraw GX to prevent accidental modification of a shape intended to be used as a constant. When
this flag is set, you cannot use the geometry-editing functions described in
the geometric shapes chapter of Inside Macintosh: QuickDraw GX Graphics and the text, glyph, and layout shapes chapters of Inside Macintosh: QuickDraw GX Typography. However, you can still alter the shape's geometric structure by accessing it directly (see "Directly Manipulating a Shape's Geometry" beginning on page 2-34).
gxGroupShape0x0010QuickDraw GX is to group all shapes
within this shape as a single shape when hit-testing. This attribute applies to picture shapes only; for more information see the picture shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxMapTransformShape0x0020QuickDraw GX is to apply shape- transforming operations to the shape's transform object rather than to the shape's geometry. This attribute is set by default
for bitmap shapes, picture shapes, and layout shapes. See the chapter "Transform
Objects" in this book for more information on applying transformations to shapes.
gxUniqueItemsShape0x0040QuickDraw GX is to create a complete copy of each shape added to this picture rather than simply creating a reference to the added shape. This attribute applies to picture shapes only; for more information see the picture shapes chapter of Inside Macintosh: QuickDraw GX Graphics.
gxIgnorePlatformShape0x0080QuickDraw GX is to treat the codes in the geometry of this shape as glyph codes rather than character codes. This attribute applies to typographic shapes only; for more information see the typographic shapes chapter of Inside Macintosh: QuickDraw GX Typography.
 
gxNoMetricsGridShape0x0100QuickDraw GX is not to use hints (special display instructions) provided with the
font used for this shape. Set this attribute
if you intend to manipulate text as a path shape; otherwise, the hinting can affect the spacing between the contours in the path's geometry and can be undesirable if you want to perform other operations such
as scaling. This attribute applies to typographic shapes only; for more information see the typographic shapes chapter of Inside Macintosh: QuickDraw GX Typography.
gxDiskShape0x0200QuickDraw GX is to write this shape to
disk before all shapes that do not have
this attribute set when it needs to unload
shapes to minimize memory requirements.
The attributes gxDiskShape and gxMemoryShape are exclusive; do not
set them both.
gxMemoryShape0x0400QuickDraw GX is to keep this shape
loaded in memory as long as possible. When this attribute is set, QuickDraw GX writes this shape out to disk after all
shapes are written that do not have
this attribute set. The attributes gxMemoryShape and gxDiskShape are exclusive; do not set them both.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996